<!--
 * @Description: 附言区域
-->
<template>
  <div class="sponsor-postscript">
    <a-spin :spinning="spinning">
      <ul class="comment-list">
        <li v-for="item in list" :key="item.id">
          <div>
            <span v-if="data" class="author-base-info" @click="showBaseInfo(item.createId)">{{
              item.createName
            }}</span
            ><span v-if="item.canView" v-html="item.escapedContent"></span>
            <span v-else>[{{ $i18n('common.display.hidden.label') }}]</span>

            <FileList
              :isDisplayAllDownload="false"
              :isInlineLayout="false"
              :attachments="item.attFileDomain"
              :relationDocs="item.assDocDomain"
              :areaName="`postscript-${item.id}`"
              :listStyle="{ maxHeight: '238px', overflowY: 'auto' }"
            />
          </div>
          <div>{{ getDateString(item.createDate) }}</div>
        </li>
      </ul>
    </a-spin>
  </div>
</template>
<script>
  //引入附件、关联列表集合
  import FileList from '@/components/classic-layout/summary/file-new';
  // 引入基础数据
  import { useBaseInfoStore } from '@/store/modules/base-info.js';
  import { mapState } from 'pinia';
  import globalMethods from '@/plugins/methods';
  import {showBaseInfo} from "@/helper/people-card";

  export default {
    name: 'SponsorPostscript',
    components: { FileList },
    props: {
      //转发传入的附言列表。纯展示。属于自由协同，先去掉
      // data: {
      //     type: Array,
      // },
      // baseInfo: {
      //   type: Object
      // },
      list: {
        type: Array
      }
    },
    data() {
      return {
        //附言数据
        dataList: [],
        //是否展示新增附言输入框
        isShowTextareaComment: false,
        spinning: false
      };
    },
    computed: {
      ...mapState(useBaseInfoStore, ['print', 'baseInfo'])
    },
    created() {
      this.showBaseInfo = showBaseInfo;
      this.getDateString = globalMethods.getDateString;
      //如果有初始值，n那么就是转发协同中的纯展示。或者就是纯展示
      // if (this.data) {
      //     this.dataList = this.data;
      // } else {
      // this.getData();
      // }
    },
    methods: {
      //获取数据
      // async getData() {
      // this.spinning = true;
      // const { moduleId, moduleType } = this.baseInfo.zwIframe.mainbody;
      // this.dataList = (
      //   await api.commentGetList({
      //     moduleId,
      //     affairId: this.baseInfo.businessData.affair.id,
      //     moduleType,
      //     queryType: 2
      //   })
      // ).commentData[0].comments;
      // //更新打印数据
      // this.print.postscriptData = this.dataList;
      // this.spinning = false;
      // },
      // refresh() {
      //   // this.getData();
      // }
    }
  };
</script>
<style lang="scss" scoped>
  .sponsor-postscript {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    overflow-y: auto;
    .comment-list {
      min-height: 20px;
      margin-right: 13px;
      margin-left: 19px;
      background-color: #fff;

      > li {
        padding-top: 10px;
        padding-bottom: 15px;
        border-bottom: #f0f0f0 1px solid;
        font-size: 14px;
        color: #333333;
        &:first-child {
          ~ li {
            border-top: $border;
          }
        }

        > div {
          &:last-child {
            margin-top: 10px;
            font-size: 12px;
            color: #999999;
          }
        }
      }
    }

    .textarea-comment {
      padding-bottom: 20px;
      margin: 0 20px;
    }
  }
</style>
